<template>
	<view>
		<!-- 商家订单列表 -->
		<view class="flex j-s a-c p20 bb" style="background-color: #fff;position: sticky;top: 0;">
			<text @click="on_tab(0)" style='padding:10rpx 40rpx 0 40rpx'
				:class="tabindex==0 ? 'tab_list' : 'tab_list_w'">进行中</text>
			<text @click="on_tab(1)" style='padding:10rpx 40rpx 0 40rpx'
				:class="tabindex==1 ? 'tab_list' : 'tab_list_w'">待审核</text>
			<text @click="on_tab(2)" style='padding:10rpx 40rpx 0 40rpx'
				:class="tabindex==2 ? 'tab_list' : 'tab_list_w'">已完成</text>
		</view>
		<orderList @myEven="on_tab(0)" :list="order_list" :islog="islog" :log="log" :tabindex="tabindex"></orderList>
	</view>
</template>
<script>
	import orderList from "@/pages/list/order_list.vue";
	export default {
		components: {
			orderList
		},
		data() {
			return {
				tabindex: 0,
				order_list: [],
				islog: true,
				page: 1,
				itype: '',
				limit: 5,
				totalPage: '',
			};
		},
		onShow() {
			console.log(uni.getStorageSync('publis').examineType)
			this.$module.ifToken(res => {
				if (res == 1) {
					this.$module.navigateTo('/pages/banmi/user_login')
				} else if (res == 3) {
					this.islog = false
				} else {
					this.itype = uni.getStorageSync('user').itype //获取用户是商家还是用户
					this.getlist() //获取数据
					return
				}
			})
		},
		methods: {
			on_tab(index) {
				this.$module.ifToken(res => {
					if (res == 1) {
						this.$module.navigateTo('/pages/banmi/user_login')
					} else if (res == 3) {
						this.islog = false
					} else {
						this.tabindex = index
						this.order_list = [];
						this.islog = true;
						this.page = 1;
						this.log = '加载中';
						this.getlist()
					}
				})
			},
			onReachBottom() {
				this.jiazai = "加载中...";
				this.page += 1;
				if (this.page > this.totalPage) {
					this.$module.showToast("已经到底了")
					return
				} else {
					this.getlist()
				}
			},
			getlist() { //获取数据信息
				var that = this;
				let data = {
					data
				}
				let requestParams = {
					limit: this.limit,
					page: this.page,
					state: this.tabindex == 2 ? '2,3,4,5,6,7' : this.tabindex
				};
				this.$module.sm(requestParams, 1, res => {
					data.data = res
				})
				this.Htpp.post('/mehrb/meplus/order/page', 'app', {
					datalist: data
				}).then(ret => {
					that.$module.sm(ret, 2, res => {
						this.totalPage = res.data.totalPage
						if (that.page == 1) {
							this.order_list = res.data.list;
						} else {
							if (res.data.list.length > 0) {
								for (var i = 0; i < res.data.list.length; i++) {
									this.order_list.push(res.data.list[i]);
								}
							}
							if (res.data.list.length < 10) {
								this.log = "没有数据了"
								return
							}
						}
						setTimeout(() => {
							that.isinit = false;
							that.islog = false;
						}, 100)
					})
				})
			}
		}
	}
</script>

<style lang="less">
	.tab_list {
		font-weight: 800;
		border-bottom: solid 5rpx #0071FE;
		padding-bottom: 10rpx;
		color: #0071FE;
	}

	.tab_list_w {
		border-bottom: solid 5rpx #fff;
		padding-bottom: 10rpx;
		color: #7B7B7B;
	}
</style>